package com.movitech.mobile.cz.base.purchase.bizservice.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.bizconfig.entity.SStrategicPartners;
import com.movitech.mobile.cz.base.bizconfig.mapper.ext.ExtSStrategicPartnersMapper;
import com.movitech.mobile.cz.base.bizconfig.service.SStrategicPartnersService;
import com.movitech.mobile.cz.base.common.aop.ServiceThrowable;
import com.movitech.mobile.cz.base.common.license.LicenseUtil;
import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.common.util.ListObjCopyUtil;
import com.movitech.mobile.cz.base.common.util.PageCode;
import com.movitech.mobile.cz.base.common.util.StringUtils;
import com.movitech.mobile.cz.base.modules.config.*;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.purchase.bizservice.IndexService;
import com.movitech.mobile.cz.base.purchase.bizvo.*;
import com.movitech.mobile.cz.base.purchase.entity.ext.ExtWFlowForm;
import com.movitech.mobile.cz.base.purchase.entity.ext.IndexMoreRequestVO;
import com.movitech.mobile.cz.base.purchase.mapper.ext.ExtWFlowFormMapper;
import com.movitech.mobile.cz.base.purchase.service.WFlowFormService;
import com.movitech.mobile.cz.base.sessionuser.SessionButtonVo;
import com.movitech.mobile.cz.base.sessionuser.SessionMenuVo;
import com.movitech.mobile.cz.base.sessionuser.SessionUserVo;
import com.movitech.mobile.cz.base.supplier.entity.SMyDeals;
import com.movitech.mobile.cz.base.supplier.entity.SSuppliers;
import com.movitech.mobile.cz.base.supplier.entity.ext.ExtSMyDeals;
import com.movitech.mobile.cz.base.supplier.service.SMyDealsService;
import com.movitech.mobile.cz.base.supplier.service.SSuppliersService;
import com.movitech.mobile.cz.base.sys.bizvo.*;
import com.movitech.mobile.cz.base.sys.entity.SAttachment;
import com.movitech.mobile.cz.base.sys.entity.SMessageTemplate;
import com.movitech.mobile.cz.base.sys.entity.SMessages;
import com.movitech.mobile.cz.base.sys.entity.SysUser;
import com.movitech.mobile.cz.base.sys.entity.ext.ExtSMessages;
import com.movitech.mobile.cz.base.sys.mapper.ext.ExtSMessagesMapper;
import com.movitech.mobile.cz.base.sys.service.*;
import com.movitech.mobile.cz.base.util.UserUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

@Service("indexService")
@Transactional
public class IndexServiceImpl implements IndexService {

	private final static Logger logger = Logger.getLogger(IndexServiceImpl.class);

	@Autowired
	private SBannerService sBannerService;

	@Autowired
	private SMessageTemplateService sMessageTemplateService;

	@Autowired
	private SMessagesService sMessagesService;


	@Autowired
	private SysUserService sysUserService;

	@Autowired
	private SMyDealsService sMyDealsService;

	@Autowired
	private SSuppliersService sSuppliersService;

	@Autowired
	private WFlowFormService wFlowFormService;

	@Autowired
	private ExtWFlowFormMapper extWFlowFormMapper;

	@Autowired
	private SAttachmentService sAttachmentService;

	@Autowired
	private ExtSMessagesMapper extSMessagesMapper;

	@Autowired
	private ExtSStrategicPartnersMapper extSStrategicPartnersMapper;

	@Autowired
	private SStrategicPartnersService sStrategicPartnersService;
	@Autowired
	private SRegionalCompanyService sRegionalCompanyService;



	/***
	 * 采购外网平台首页
	 * @return
	 */
	@Override
	public RestReturnResult getRestIndex(HttpServletResponse response, HttpServletRequest request) {
		RestReturnResult restResult = RestReturnResult.error();
		try {
			IndexResponseVO indexResponseVO=new IndexResponseVO();
			//查询banner信息
//			EntityWrapper wrapper = new EntityWrapper<>();
//			SBanner sBanner=new SBanner();
//			sBanner.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
//			wrapper.setEntity(sBanner);
//			wrapper.orderBy(" banner_sort ",true);
//			List<SBanner> ls=sBannerService.selectList(wrapper);
//			List<BannerResponseVO> bannerResponseVOls = ListObjCopyUtil.copyTo(ls, BannerResponseVO.class);
//			for(BannerResponseVO bannerResponseVO:bannerResponseVOls){
//				EntityWrapper entityWrapper = new EntityWrapper<>();
//				SAttachment obj=new SAttachment();
//				obj.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
//				obj.setRelatedId(bannerResponseVO.getId());
//				obj.setAttachmentType(AttachmentTypeEnum.ATTACHMENT_TYPE_34.getCode());
//				entityWrapper.setEntity(obj);
//				SAttachment sAttachment=sAttachmentService.selectOne(entityWrapper);
//				if(sAttachment!=null){
//					AttachmentVO attachmentVO=new AttachmentVO();
//					BeanUtils.copyProperties(sAttachment,attachmentVO);
//					bannerResponseVO.setAttachmentVo(attachmentVO);
//				}
//			}
//			indexResponseVO.setLstBannerResponseVO(bannerResponseVOls);

			//查询用户信息
//			String userId=request.getHeader("user_info");
			String userId=UserUtils.getOuterCurrentUserId();
//			String userId=HeadersUtils.getHeadByKey(request,"user_info");
			if(StringUtils.isNotEmpty(userId)){
				SysUser sysuser=sysUserService.selectById(userId);
				if(sysuser!=null){
					EntityWrapper objectEntityWrapper = new EntityWrapper<>();
					SSuppliers wrapperSupplier=new SSuppliers();
					wrapperSupplier.setSysUserId(userId);
					wrapperSupplier.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
					objectEntityWrapper.setEntity(wrapperSupplier);
					SSuppliers sSuppliers=sSuppliersService.selectOne(objectEntityWrapper);
					UserResponseVO userResponseVO=new UserResponseVO();
					userResponseVO.setUserId(sysuser.getId());
					userResponseVO.setUserName(sysuser.getLoginName());
					if(sSuppliers!=null){
						userResponseVO.setSuppliersId(sSuppliers.getId());
						userResponseVO.setCompanyName(sSuppliers.getCompanyName());
					}
					indexResponseVO.setUserResponseVo(userResponseVO);
				}
			}

			//招标公告
			EntityWrapper entityWrapper = new EntityWrapper<>();
			entityWrapper.in(" msg_type ",MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode());
			entityWrapper.orderBy(" update_date ",false);
			entityWrapper.last(" limit 8 ");
			entityWrapper.where(" del_flag = "+CommonConstants.DEL_FLAG_NORMAL);
			List<SMessages> lstTenderBidMessage=sMessagesService.selectList(entityWrapper);
			if(lstTenderBidMessage!=null&&lstTenderBidMessage.size()>0){
				List<MessageResponseVO> lstTenderBidMessageResponseVO=ListObjCopyUtil.copyTo(lstTenderBidMessage, MessageResponseVO.class);
				indexResponseVO.setLstTenderBidMessageResponseVO(lstTenderBidMessageResponseVO);
			}
			//中标公告
			entityWrapper=new EntityWrapper<>();
			entityWrapper.in(" msg_type ",MessagesMsgTypeEnum.MsgType7.getCode()+"");
			entityWrapper.orderBy(" update_date ",false);
			entityWrapper.last(" limit 8 ");
			entityWrapper.where(" del_flag = "+CommonConstants.DEL_FLAG_NORMAL);
			List<SMessages> lstWinBidMessage=sMessagesService.selectList(entityWrapper);
			if(lstTenderBidMessage!=null&&lstTenderBidMessage.size()>0){
				List<MessageResponseVO> lstWinBidMessageResponseVO=ListObjCopyUtil.copyTo(lstWinBidMessage, MessageResponseVO.class);
				indexResponseVO.setLstWinBidMessageResponseVO(lstWinBidMessageResponseVO);
			}

			LicenseUtil.INSTANCE.validate();
			//战略合作伙伴
			List<StrategicPartnersResponseVO> lsStrategicPartnersResponseVO=new ArrayList<>();
			SStrategicPartners sStrategicPartners=new SStrategicPartners();
			sStrategicPartners.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
			sStrategicPartners.setPartnerStatus(CommonConstants.YES_INTEGER);
			List<SStrategicPartners> sStrategicPartnersList=sStrategicPartnersService.selectList(new EntityWrapper<SStrategicPartners>(sStrategicPartners));
//			List<ExtSStrategicPartners> lsExtSStrategicPartners = extSStrategicPartnersMapper.getStrategicPartnersList(new HashMap<>());
			if(sStrategicPartnersList != null && sStrategicPartnersList.size() > 0){
				List<StrategicPartnersListResponseVO> result = ListObjCopyUtil.copyTo(sStrategicPartnersList, StrategicPartnersListResponseVO.class);
				EntityWrapper wrapperObj = new EntityWrapper();
				SAttachment param = new SAttachment();
				for(StrategicPartnersListResponseVO vo : result){
					param.setRelatedId(vo.getId());
					param.setAttachmentType(AttachmentTypeEnum.ATTACHMENT_TYPE_35.getCode());
					//param.setAttachmentSubType(AttachmentSubTypeEnum.ATTACHMENTSUBTYPE_2.getCode());
					param.setDelFlag(CommonConstants.NO_INTEGER);
					wrapperObj.setEntity(param);
					List<SAttachment> attachments = sAttachmentService.selectList(wrapperObj);
					List<AttachmentVO> lstAttachments = ListObjCopyUtil.copyTo(attachments, AttachmentVO.class);
					for(AttachmentVO attachmentVO:lstAttachments){
						StrategicPartnersResponseVO strategicPartnersResponseVO=new StrategicPartnersResponseVO();
						strategicPartnersResponseVO.setAttachmentVo(attachmentVO);
						strategicPartnersResponseVO.setPartnerName(vo.getPartnerName());
						lsStrategicPartnersResponseVO.add(strategicPartnersResponseVO);
					}
				}
			}
			indexResponseVO.setLstStrategicPartnersResponseVO(lsStrategicPartnersResponseVO);
			restResult = RestReturnResult.success();
			restResult.setData(indexResponseVO);
		} catch (Exception e) {
			e.printStackTrace();
			restResult = RestReturnResult.error();
		}
		return restResult;
	}


	@Override
	public RestReturnResult<Object> initHome() {
		RestReturnResult<Object> hResult = RestReturnResult.error();
		PurchaseManageHomeResponseVO purchaseManageHomeResponseVO = new PurchaseManageHomeResponseVO();

		try{
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("noticeShowNum", CommonConstants.NOTICE_SHOW_NUM);
			map.put("msgType", MessagesMsgTypeEnum.MsgType1.getCode()+","+MessagesMsgTypeEnum.MsgType6.getCode());
//			String userId = "MG1930";
			SessionUserVo sessionUserVo=UserUtils.getCurrentUserVo();
			if(sessionUserVo==null||StringUtils.isEmpty(sessionUserVo.getEmployeeID())){
				hResult.setData(purchaseManageHomeResponseVO);
				return hResult;
			}
			String userId = sessionUserVo.getEmployeeID();
			map.put("userId", userId);
			map.put("pageFlag", 0);
//			map.put("msgType", MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode());
			//公告通知
			List<ExtSMessages> msgList =sMessagesService.getNoticeListByShowNum(map);
			List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(msgList, NoticeResponseVO.class);
			for(NoticeResponseVO noticeResponseVO:noticeList){
				noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
			}
			purchaseManageHomeResponseVO.setLstNoticeResponseVO(noticeList);


			LicenseUtil.INSTANCE.validate();
			map.put("doneFlag", CommonConstants.NO_INTEGER);
			//我的待办总数
			map.put("noticeShowNum", null);
			List<SMyDeals> totalMyDeals = sMyDealsService.getMyDealsListByUserAndStatus(map);
			if(totalMyDeals!=null)purchaseManageHomeResponseVO.setTotalWaitingDeals(totalMyDeals.size());
			//我的待办
			map.put("noticeShowNum", CommonConstants.NOTICE_SHOW_NUM);
			List<SMyDeals> watingDealList = sMyDealsService.getMyDealsListByUserAndStatus(map);
			List<MyDealsResponseVO> myWaitingDealList = ListObjCopyUtil.copyTo(watingDealList, MyDealsResponseVO.class);
			purchaseManageHomeResponseVO.setLstMyWaitingDealsResponseVO(myWaitingDealList);

			map.put("doneFlag", CommonConstants.YES_INTEGER);
			//我的已办
			List<SMyDeals> hadDealtList = sMyDealsService.getMyDealsListByUserAndStatus(map);
			List<MyDealsResponseVO> myHadDealList = ListObjCopyUtil.copyTo(hadDealtList, MyDealsResponseVO.class);
			purchaseManageHomeResponseVO.setLstMyHadDealsResponseVO(myHadDealList);

			//用户信息
			CurrentUserResponseVO currentUserResponseVO=new CurrentUserResponseVO();
			if(sessionUserVo!=null) {
				BeanUtils.copyProperties(sessionUserVo,currentUserResponseVO);
				currentUserResponseVO.setId(sessionUserVo.getEmployeeID());
				//保存用户信息
				SysUser userOld=sysUserService.selectById(sessionUserVo.getEmployeeID());
				if(userOld==null){
					SysUser leaderUser=new SysUser();
					leaderUser.setPassword(DigestUtils.md5Hex("abc123456"));//默认abc123456
					leaderUser.setUserType(CommonConstants.INNER_USER);
					leaderUser.setLoginFlag(CommonConstants.YES_LOGIN);
					leaderUser.setId(sessionUserVo.getEmployeeID());
					leaderUser.setLoginName(sessionUserVo.getEmployeeID());
					leaderUser.setUserCode(sessionUserVo.getEmployeeID());
					leaderUser.setName(sessionUserVo.getRealName());
					leaderUser.setBaseFeilds(sessionUserVo.getEmployeeID(),null,0,true);
					sysUserService.insert(leaderUser);
				}else{
					if(!userOld.getName().equals(sessionUserVo.getRealName())){
						userOld.setName(sessionUserVo.getRealName());
						userOld.setUpdateDate(new Date());
						userOld.setBaseFeilds(sessionUserVo.getEmployeeID(),null,0,false);
						sysUserService.updateById(userOld);
					}
				}
			}
			purchaseManageHomeResponseVO.setCurrentUserResponseVO(currentUserResponseVO);

			//用户菜单
			List<SessionMenuVo> menuVoList=UserUtils.getCurrentUserMenu();
			List<MenuResponseVO> lstMenuResponseVO =new ArrayList<>();
			if(menuVoList!=null&&menuVoList.size()>0)lstMenuResponseVO = ListObjCopyUtil.copyTo(menuVoList, MenuResponseVO.class);
			purchaseManageHomeResponseVO.setLstMenuResponseVO(lstMenuResponseVO);

			hResult = RestReturnResult.success();
			hResult.setData(purchaseManageHomeResponseVO);
		}catch(Exception e){
			e.printStackTrace();
			hResult = RestReturnResult.error();
		}
		return hResult;
	}

	@Override
	public RestReturnResult<Object> moreInfo(IndexMoreRequestVO indexMoreRequestVO) {
		RestReturnResult<Object> hResult = RestReturnResult.error();

		try{
			if(indexMoreRequestVO.getPageFlag()!=null&&indexMoreRequestVO.getPageFlag().equals(CommonConstants.YES_INTEGER)){
				EntityWrapper wrapper = new EntityWrapper<>();
				if(indexMoreRequestVO.getResultType()==null||"1".equals(indexMoreRequestVO.getResultType())){//更多类型  1公告 2待办 3已办 4招标 5中标

					PageCode pageCode = new PageCode(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize());
					Map<String, Object> map = new HashMap<String, Object>();
					String userId = UserUtils.getCurrentUserId();
					map.put("userId", userId);
					map.put("title",indexMoreRequestVO.getMsgTitle());
//					map.put("extraMsgType", MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode());
//					map.put("extraMsgType", MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode()
//							+","+MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode());
					map.put("msgType", MessagesMsgTypeEnum.MsgType1.getCode()+","+MessagesMsgTypeEnum.MsgType6.getCode());

					pageCode.setCount(sMessagesService.getNoticeListCount(map));

					map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
		            map.put("pageSize", pageCode.getPageSize());
		            map.put("pageFlag", indexMoreRequestVO.getPageFlag());

		            List<ExtSMessages> msgList =sMessagesService.getNoticeListByShowNum(map);
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(msgList, NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}

					pageCode.setList(noticeList);

					hResult = new RestReturnResult(CommonConstants.SUCCESS, pageCode);

				}else if("2".equals(indexMoreRequestVO.getResultType())){
					Page<SMyDeals> page=new Page(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize(), " update_date ", false);
					String userId = UserUtils.getCurrentUserId();
					SMyDeals sMyDeals=new SMyDeals();
					sMyDeals.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
					sMyDeals.setUserId(userId);
					sMyDeals.setDoneFlag(CommonConstants.NO_INTEGER);
					wrapper.setEntity(sMyDeals);
					if(StringUtils.isNotEmpty(indexMoreRequestVO.getMsgTitle())){
						wrapper.like("deal_title",indexMoreRequestVO.getMsgTitle());
					}
					//我的待办
					Page<SMyDeals> sMyDealsPage= sMyDealsService.selectPage(page,wrapper);
					Page<MyDealsResponseVO> MyDealsResponseVOPage= new Page<MyDealsResponseVO>();
					List<MyDealsResponseVO> myDealsResponseVOList = ListObjCopyUtil.copyTo(sMyDealsPage.getRecords(), MyDealsResponseVO.class);
					MyDealsResponseVOPage.setRecords(myDealsResponseVOList);
					MyDealsResponseVOPage.setTotal(sMyDealsPage.getTotal());
					MyDealsResponseVOPage.setSize(sMyDealsPage.getSize());
					MyDealsResponseVOPage.setCurrent(sMyDealsPage.getCurrent());
					hResult = RestReturnResult.success();
					hResult.setData(MyDealsResponseVOPage);
				}else if("3".equals(indexMoreRequestVO.getResultType())){
					Page<SMyDeals> page=new Page(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize(), " update_date ", false);
					String userId = UserUtils.getCurrentUserId();
					SMyDeals sMyDeals=new SMyDeals();
					sMyDeals.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
					sMyDeals.setUserId(userId);
					sMyDeals.setDoneFlag(CommonConstants.YES_INTEGER);
					sMyDeals.setUpdateBy(userId);
					wrapper.setEntity(sMyDeals);
					if(StringUtils.isNotEmpty(indexMoreRequestVO.getMsgTitle())){
						wrapper.like("deal_title",indexMoreRequestVO.getMsgTitle());
					}
					//我的已办
					Page<SMyDeals> sMyDealsPage= sMyDealsService.selectPage(page,wrapper);
					Page<MyDealsResponseVO> MyDealsResponseVOPage= new Page<MyDealsResponseVO>();
					List<MyDealsResponseVO> myDealsResponseVOList = ListObjCopyUtil.copyTo(sMyDealsPage.getRecords(), MyDealsResponseVO.class);
					MyDealsResponseVOPage.setRecords(myDealsResponseVOList);
					MyDealsResponseVOPage.setTotal(sMyDealsPage.getTotal());
					MyDealsResponseVOPage.setSize(sMyDealsPage.getSize());
					MyDealsResponseVOPage.setCurrent(sMyDealsPage.getCurrent());
					hResult = RestReturnResult.success();
					hResult.setData(MyDealsResponseVOPage);
				}else if("4".equals(indexMoreRequestVO.getResultType())){//招标公告
					Page<SMessages> page=new Page(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize(), " update_date ", false);
					EntityWrapper entityWrapper = new EntityWrapper<>();
					entityWrapper.in(" msg_type ",MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode());
					if(StringUtils.isNotEmpty(indexMoreRequestVO.getMsgTitle())){
						entityWrapper.like("msg_title",indexMoreRequestVO.getMsgTitle());
					}
					entityWrapper.where(" del_flag = "+CommonConstants.DEL_FLAG_NORMAL);
					Page<SMessages> sMessagesPage= sMessagesService.selectPage(page,entityWrapper);
					Page<NoticeResponseVO> noticeResponseVOPage= new Page<NoticeResponseVO>();
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(sMessagesPage.getRecords(), NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					noticeResponseVOPage.setRecords(noticeList);
					noticeResponseVOPage.setTotal(sMessagesPage.getTotal());
					noticeResponseVOPage.setSize(sMessagesPage.getSize());
					noticeResponseVOPage.setCurrent(sMessagesPage.getCurrent());
					hResult = RestReturnResult.success();
					hResult.setData(noticeResponseVOPage);
				}else if("5".equals(indexMoreRequestVO.getResultType())){//中标公告
					Page<SMessages> page=new Page(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize(), " update_date ", false);
					//公告通知
					SMessages sMessages=new SMessages();
					sMessages.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
					sMessages.setMsgType(MessagesMsgTypeEnum.MsgType7.getCode());
					wrapper.setEntity(sMessages);
					if(StringUtils.isNotEmpty(indexMoreRequestVO.getMsgTitle())){
						wrapper.like("msg_title",indexMoreRequestVO.getMsgTitle());
					}
					Page<SMessages> sMessagesPage= sMessagesService.selectPage(page,wrapper);
					Page<NoticeResponseVO> noticeResponseVOPage= new Page<NoticeResponseVO>();
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(sMessagesPage.getRecords(), NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					noticeResponseVOPage.setRecords(noticeList);
					noticeResponseVOPage.setTotal(sMessagesPage.getTotal());
					noticeResponseVOPage.setSize(sMessagesPage.getSize());
					noticeResponseVOPage.setCurrent(sMessagesPage.getCurrent());
					hResult = RestReturnResult.success();
					hResult.setData(noticeResponseVOPage);
				}
			}else{
				Object obj=new Object();
				Map<String, Object> map = new HashMap<String, Object>();
				if(indexMoreRequestVO.getResultType()==null||"1".equals(indexMoreRequestVO.getResultType())){
					//公告通知
					String userId = UserUtils.getCurrentUserId();
					map.put("userId", userId);
//					map.put("extraMsgType", MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode());
					map.put("msgType", MessagesMsgTypeEnum.MsgType1.getCode()+","+MessagesMsgTypeEnum.MsgType6.getCode());
					List<ExtSMessages> msgList =sMessagesService.getNoticeListByShowNum(map);
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(msgList, NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					obj=noticeList;
				}else if("2".equals(indexMoreRequestVO.getResultType())){
					String userId = UserUtils.getCurrentUserId();
					map.put("userId", userId);
					map.put("doneFlag", CommonConstants.NO_INTEGER);
					//我的待办
					List<SMyDeals> watingDealList = sMyDealsService.getMyDealsListByUserAndStatus(map);
					List<MyDealsResponseVO> myWaitingDealList = ListObjCopyUtil.copyTo(watingDealList, MyDealsResponseVO.class);
					obj=myWaitingDealList;
				}else if("3".equals(indexMoreRequestVO.getResultType())){
					String userId = UserUtils.getCurrentUserId();
					map.put("userId", userId);
					map.put("doneFlag", CommonConstants.YES_INTEGER);
					//我的已办
					List<SMyDeals> hadDealtList = sMyDealsService.getMyDealsListByUserAndStatus(map);
					List<MyDealsResponseVO> myHadDealList = ListObjCopyUtil.copyTo(hadDealtList, MyDealsResponseVO.class);
					obj=myHadDealList;
				}else if("4".equals(indexMoreRequestVO.getResultType())){//招标公告
					EntityWrapper entityWrapper = new EntityWrapper<>();
					entityWrapper.in(" msg_type ",MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode());
					entityWrapper.orderBy(" update_date ",false);
					entityWrapper.where(" del_flag = "+CommonConstants.DEL_FLAG_NORMAL);
					List<SMessages> msgList =sMessagesService.selectList(entityWrapper);
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(msgList, NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					obj=noticeList;
				}else if("5".equals(indexMoreRequestVO.getResultType())){//中标公告
					EntityWrapper wrapper = new EntityWrapper<>();
					SMessages sMessages=new SMessages();
					sMessages.setDelFlag(CommonConstants.DEL_FLAG_NORMAL);
					sMessages.setMsgType(MessagesMsgTypeEnum.MsgType7.getCode());
					wrapper.setEntity(sMessages);
					wrapper.orderBy(" update_date ",false);
					List<SMessages> ls=sMessagesService.selectList(wrapper);
					List<NoticeResponseVO> noticeList = ListObjCopyUtil.copyTo(ls, NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					obj=noticeList;
				}
				hResult = RestReturnResult.success();
				hResult.setData(obj);
			}
		}catch(Exception e){
			e.printStackTrace();
			hResult = RestReturnResult.error();
		}

		return hResult;
	}

	@Override
	public RestReturnResult<Object> getNoticeDetail(String messageId) {
		RestReturnResult<Object> hResult = RestReturnResult.error();

		try{
			SMessageTemplate messageTemplate = sMessageTemplateService.selectById(messageId);
			NoticeResponseVO noticeResponseVO = new NoticeResponseVO();
			BeanUtils.copyProperties(messageTemplate, noticeResponseVO);

			hResult = RestReturnResult.success();
			hResult.setData(noticeResponseVO);
		}catch(Exception e){
			e.printStackTrace();
			hResult = RestReturnResult.error();
		}

		return hResult;
	}

	@Override
	public RestReturnResult<Object> innerUserInfo() {
		RestReturnResult<Object> hResult = RestReturnResult.error();
		InnerUserResponseVO innerUserResponseVO=new InnerUserResponseVO();
		try {
			//用户信息
			CurrentUserResponseVO currentUserResponseVO=new CurrentUserResponseVO();
			SessionUserVo sessionUserVo=UserUtils.getCurrentUserVo();
			if(sessionUserVo!=null) {
				BeanUtils.copyProperties(sessionUserVo,currentUserResponseVO);
				currentUserResponseVO.setAdminCIds(sRegionalCompanyService.findAdminCIdsBySupplierId(sessionUserVo.getEmployeeID()));
				currentUserResponseVO.setId(sessionUserVo.getEmployeeID());
			}
			innerUserResponseVO.setCurrentUserResponseVO(currentUserResponseVO);
			//用户菜单
			List<SessionMenuVo> menuVoList=UserUtils.getCurrentUserMenu();
			List<MenuResponseVO> lstMenuResponseVO =new ArrayList<>();
			if(menuVoList!=null&&menuVoList.size()>0)lstMenuResponseVO = ListObjCopyUtil.copyTo(menuVoList, MenuResponseVO.class);
			innerUserResponseVO.setLstMenuResponseVO(lstMenuResponseVO);

			//用户按钮
			List<SessionButtonVo> sessionButtonVoList=UserUtils.getCurrentUserButton();
			List<CurrentUserButtonVO> lstCurrentUserButtonVO=new ArrayList<>();
			if(sessionButtonVoList!=null&&sessionButtonVoList.size()>0)lstCurrentUserButtonVO = ListObjCopyUtil.copyTo(sessionButtonVoList, CurrentUserButtonVO.class);
			innerUserResponseVO.setCurrentUserButtonVO(lstCurrentUserButtonVO);


			LicenseUtil.INSTANCE.validate();

			hResult = RestReturnResult.success();
			hResult.setData(innerUserResponseVO);
		}catch (Exception e){
			e.printStackTrace();
			hResult = RestReturnResult.error();
		}
		return hResult;
	}

	@Override
	public RestReturnResult<Object> getNoticeDesc(String messageId) {
		RestReturnResult<Object> hResult = new RestReturnResult<Object>(CommonConstants.FAIL, CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
		SMessages sMessages=sMessagesService.selectById(messageId);
		if(sMessages==null||StringUtils.isEmpty(sMessages.getFlowFormId())){
			throw new RuntimeException("数据不存在",new ServiceThrowable());
		}
		ExtWFlowForm extWFlowForm=extWFlowFormMapper.getExtById(sMessages.getFlowFormId());
		hResult=RestReturnResult.success();
		hResult.setData(extWFlowForm);
		return hResult;
	}

	@Override
	public RestReturnResult<Object> bidList(IndexMoreRequestVO indexMoreRequestVO) {
		RestReturnResult<Object> hResult = RestReturnResult.error();
		try{
			if(indexMoreRequestVO.getPageFlag()!=null&&indexMoreRequestVO.getPageFlag().equals(CommonConstants.YES_INTEGER)){
				if("4".equals(indexMoreRequestVO.getResultType())){//招标公告
					PageCode pageCode = new PageCode(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize());
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
					map.put("pageSize", pageCode.getPageSize());
					map.put("categoryId", indexMoreRequestVO.getCategoryId());
					map.put("msgTitle", indexMoreRequestVO.getMsgTitle());
					map.put("pageFlag", indexMoreRequestVO.getPageFlag());
					map.put("msgType",MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode());
					Integer count = extSMessagesMapper.getMessagesListCount(map);
					pageCode.setCount(count == null ? 0 : count);
					List<ExtSMessages> ls= extSMessagesMapper.getMessagesList(map);
					List<NoticeResponseVO> noticeList =ListObjCopyUtil.copyTo(ls,NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					pageCode.setList(noticeList);
					hResult = RestReturnResult.success();
					hResult.setData(pageCode);
				}else if("5".equals(indexMoreRequestVO.getResultType())){//中标公告
					PageCode pageCode = new PageCode(indexMoreRequestVO.getPageNumber(), indexMoreRequestVO.getPageSize());
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
					map.put("pageSize", pageCode.getPageSize());
					map.put("categoryId", indexMoreRequestVO.getCategoryId());
					map.put("msgTitle", indexMoreRequestVO.getMsgTitle());
					map.put("msgType",MessagesMsgTypeEnum.MsgType7.getCode());
					map.put("pageFlag", indexMoreRequestVO.getPageFlag());
					Integer count = extSMessagesMapper.getMessagesListCount(map);
					pageCode.setCount(count == null ? 0 : count);
					List<ExtSMessages> ls= extSMessagesMapper.getMessagesList(map);
					List<NoticeResponseVO> noticeList =ListObjCopyUtil.copyTo(ls,NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					pageCode.setList(noticeList);
					hResult = RestReturnResult.success();
					hResult.setData(pageCode);
				}
			}else{
				Object obj=new Object();
				if("4".equals(indexMoreRequestVO.getResultType())){//招标公告
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("categoryId", indexMoreRequestVO.getCategoryId());
					map.put("msgTitle", indexMoreRequestVO.getMsgTitle());
					map.put("msgType",MessagesMsgTypeEnum.MsgType2.getCode()+","+MessagesMsgTypeEnum.MsgType3.getCode());
					map.put("pageFlag", indexMoreRequestVO.getPageFlag());
					List<ExtSMessages> ls= extSMessagesMapper.getMessagesList(map);
					List<NoticeResponseVO> noticeList =ListObjCopyUtil.copyTo(ls,NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					obj=noticeList;
				}else if("5".equals(indexMoreRequestVO.getResultType())){//中标公告
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("categoryId", indexMoreRequestVO.getCategoryId());
					map.put("msgTitle", indexMoreRequestVO.getMsgTitle());
					map.put("msgType",MessagesMsgTypeEnum.MsgType7.getCode());
					map.put("pageFlag", indexMoreRequestVO.getPageFlag());
					List<ExtSMessages> ls= extSMessagesMapper.getMessagesList(map);
					List<NoticeResponseVO> noticeList =ListObjCopyUtil.copyTo(ls,NoticeResponseVO.class);
					for(NoticeResponseVO noticeResponseVO:noticeList){
						noticeResponseVO.setMsgTypeDesc(MessagesMsgTypeEnum.getDesc(noticeResponseVO.getMsgType()));
					}
					obj=noticeList;
				}
				hResult = RestReturnResult.success();
				hResult.setData(obj);
			}
		}catch(Exception e){
			e.printStackTrace();
			hResult = RestReturnResult.error();
		}

		return hResult;
	}


	@Override
	public RestReturnResult<Object> initHomeForMobileSupplier(MSupplierHomeInitRequestVO vo) {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			if(vo != null){

				if(vo.getNotificationShowNum() == 0){
					vo.setNotificationShowNum(3);
				}

				MSupplierHomeInitResponseVO result = new MSupplierHomeInitResponseVO();
				String userId = UserUtils.getOuterCurrentUserId();
				//外网根据供方id查询，扩展：未来一个供方对应对应多个用户
				SSuppliers sSuppliers = sSuppliersService.getBySysUserId(userId);
				String supplierId = null;
				if(sSuppliers != null){
					supplierId = sSuppliers.getId();
				}

				//通知
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("userId", userId);
				param.put("noticeShowNum", vo.getNotificationShowNum());
//				param.put("msgType", MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode()+","
//						+MessagesMsgTypeEnum.MsgType11.getCode()+","
//						+MessagesMsgTypeEnum.MsgType12.getCode()
//						+","+MessagesMsgTypeEnum.MsgType8.getCode()
//						+","+MessagesMsgTypeEnum.MsgType9.getCode()
//						+","+MessagesMsgTypeEnum.MsgType10.getCode()
//						+","+MessagesMsgTypeEnum.MsgType13.getCode()
//						+","+MessagesMsgTypeEnum.MsgType14.getCode());
//
//				List<ExtSMessages> notificationList = sMessagesService.getNoticeListByShowNum(param);
//				result.setNotificationList(notificationList);

				//待办
				List<Integer> dealSubTypeList = new ArrayList<Integer>();
				dealSubTypeList.add(MyDealSubTypeEnum.QUALIFICATION_INSPECTION.getCode());
				dealSubTypeList.add(MyDealSubTypeEnum.SITE_INSPECTION.getCode());
				dealSubTypeList.add(MyDealSubTypeEnum.STORE_APPOVE.getCode());
				dealSubTypeList.add(MyDealSubTypeEnum.SUPPLIERS_CHANGE.getCode());

				int toDoListCounts = sMyDealsService.getToDoOrDoneListCounts(supplierId, DealTypeEnum.PURCHASE.getCode(), null, false, CommonConstants.UNDONG_FLAG);
				result.setToDoListCounts(toDoListCounts);

				//邀请函
				param.put("actionType",MyDealActionTypeEnum.PPLAN_INVITATION_OUT.getCode());
				param.put("doneFlag",CommonConstants.DEL_FLAG_NORMAL);
				param.put("userId",supplierId);
				result.setInvaildCount(sMyDealsService.getMyDealListByParamsCounts(param));

				//消息
				List<Integer> msgTypeList = new ArrayList<Integer>();
				msgTypeList.add(MessagesMsgTypeEnum.MsgType3.getCode());
				msgTypeList.add(MessagesMsgTypeEnum.MsgType4.getCode());

//				int messageCounts = sMessagesService.getMessageCounts(userId, null, false);
//				messageCounts+=sMessagesService.getMessageCounts(supplierId, null, false);

				EntityWrapper wrapperObj = new EntityWrapper<>();
				wrapperObj.in("msg_type",MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode()+","
						+MessagesMsgTypeEnum.MsgType11.getCode()+","
						+MessagesMsgTypeEnum.MsgType12.getCode()
						+","+MessagesMsgTypeEnum.MsgType8.getCode()
						+","+MessagesMsgTypeEnum.MsgType9.getCode()
						+","+MessagesMsgTypeEnum.MsgType10.getCode()
						+","+MessagesMsgTypeEnum.MsgType13.getCode()
						+","+MessagesMsgTypeEnum.MsgType14.getCode()
				).eq("del_flag",CommonConstants.DEL_FLAG_NORMAL).eq("read_flag",0)
						.andNew("user_ids='"+userId+"'").or("user_ids ='"+supplierId+"'");

				result.setMessageCounts(sMessagesService.selectCount(wrapperObj));
				restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS, result);
			}else{
				throw new RuntimeException("传参为空", new ServiceThrowable());
			}

		}catch(Exception e){
			e.printStackTrace();
			logger.error("===========initHomeForMobile============e:====" + e.getMessage());
			throw new RuntimeException(e.getMessage(), e.getCause());
		}

		return restReturnResult;
	}


	@Override
	public RestReturnResult<Object> getinvitationListForMobile(MInvitationListRequestVO vo) {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			if(vo != null){

				PageCode pageCode = new PageCode(vo.getPageNumber(), vo.getPageSize());

				//获取邀请函
				Map<String, Object> map = new HashMap<String, Object>();

				String userId = UserUtils.getCurrentUserId();
				SSuppliers sSuppliers = sSuppliersService.getBySysUserId(userId);

				//外网根据供方id查询，扩展：未来一个供方对应对应多个用户
				if(sSuppliers != null){
					map.put("userId", sSuppliers.getId());
				}

				map.put("dealType", DealTypeEnum.PURCHASE.getCode());
				map.put("actionType", MyDealActionTypeEnum.PPLAN_INVITATION_OUT.getCode());
				map.put("dealTitle", vo.getDealTitle());

				pageCode.setCount(sMyDealsService.getMyDealListByParamsCounts(map));

				map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
	            map.put("pageSize", pageCode.getPageSize());
	            map.put("pageFlag", vo.getPageFlag());

				List<ExtSMyDeals> list = sMyDealsService.getMyDealListByParams(map);
				pageCode.setList(list);

				return new RestReturnResult<Object>(CommonConstants.SUCCESS, pageCode);

			}else{
				throw new RuntimeException("传参为空", new ServiceThrowable());
			}

		}catch(Exception e){
			e.printStackTrace();
			logger.error("=========getinvitationListForMobile=========e:===="+e.getMessage());
			throw new RuntimeException(e.getMessage(), e.getCause());
		}

	}


	@Override
	public RestReturnResult<Object> getToDoList(MToDoListRequestVO vo) {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			if(vo != null){

				PageCode pageCode = new PageCode(vo.getPageNumber(), vo.getPageSize());

				Map<String, Object> map = new HashMap<String, Object>();

				String userId = UserUtils.getCurrentUserId();
				SSuppliers sSuppliers = sSuppliersService.getBySysUserId(userId);

				//外网根据供方id查询，扩展：未来一个供方对应对应多个用户
				if(sSuppliers != null){
					map.put("userId", sSuppliers.getId());
				}
				map.put("dealTitle", vo.getDealTitle());
				map.put("doneFlag", CommonConstants.UNDONG_FLAG);

				pageCode.setCount(sMyDealsService.getMyDealListByParamsCounts(map));

				map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
	            map.put("pageSize", pageCode.getPageSize());
	            map.put("pageFlag", vo.getPageFlag());

				List<ExtSMyDeals> list = sMyDealsService.getMyDealListByParams(map);
				pageCode.setList(list);

				return new RestReturnResult<Object>(CommonConstants.SUCCESS, pageCode);

			}else{
				throw new RuntimeException("传参为空", new ServiceThrowable());
			}

		}catch(Exception e){
			e.printStackTrace();
			logger.error("============getToDoList===========e:====" + e.getMessage());
			throw new RuntimeException(e.getMessage(), e.getCause());
		}

	}


	@Override
	public RestReturnResult<Object> getMessageList(MMessageListRequestVO vo) {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			PageCode pageCode = new PageCode(vo.getPageNumber(), vo.getPageSize());

			Map<String, Object> map = new HashMap<String, Object>();
			map.put("userId", UserUtils.getCurrentUserId());
			map.put("msgTitle", vo.getMsgTitle());

			pageCode.setCount(sMessagesService.getMessageListByParamsCounts(map));

			map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
            map.put("pageSize", pageCode.getPageSize());
            map.put("pageFlag", vo.getPageFlag());

			List<ExtSMessages> list = sMessagesService.getMessageListByParams(map);
			pageCode.setList(list);

			return new RestReturnResult<Object>(CommonConstants.SUCCESS, pageCode);

		}catch(Exception e){
			e.printStackTrace();
			logger.error("=============getMessageList===============e:====" + e.getMessage());
		}

		return restReturnResult;
	}


	@Override
	public RestReturnResult<Object> initHomeForMobileOwnApp() {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			LicenseUtil.INSTANCE.validate();
			MOwnerAPPHomeInitResponseVO result = new MOwnerAPPHomeInitResponseVO();

			//我的待办数量
			String userId = UserUtils.getCurrentUserId();
			int toDoListCounts = sMyDealsService.getToDoOrDoneListCounts(userId, DealTypeEnum.SUPPLIERS.getCode(), null, false, CommonConstants.UNDONG_FLAG);
			result.setToDoListCounts(toDoListCounts);

			//我的已办数量
			int haveDoneListCounts = sMyDealsService.getToDoOrDoneListCounts(userId, DealTypeEnum.SUPPLIERS.getCode(), null, false, CommonConstants.DONG_FLAG);
			result.setHaveDoneListCounts(haveDoneListCounts);

			Map<String, Object> map = new HashMap<String, Object>();
			map.put("userId", UserUtils.getCurrentUserId());
			map.put("msgType", MessagesMsgTypeEnum.ANNOUNCEMENT_NOTICE.getCode());
			map.put("readFlag", CommonConstants.UNDONG_FLAG);

			int announcementCounts = (int) sMessagesService.getMessageListByParamsCounts(map);
			result.setAnnouncementCounts(announcementCounts);

			return new RestReturnResult<Object>(CommonConstants.SUCCESS, result);

		}catch(Exception e){
			e.printStackTrace();
			logger.error("===========initHomeForMobileOwnApp========e:====" + e.getMessage());
			throw new RuntimeException(e.getMessage(), e.getCause());
		}

	}


	@Override
	public RestReturnResult<Object> getToDoOrDoneListForMobileOwnApp(MToDoListOwnAppRequestVO vo) {
		RestReturnResult<Object> restReturnResult = new RestReturnResult<Object>(CommonConstants.SUCCESS);

		try{

			if(vo != null){

				PageCode pageCode = new PageCode(vo.getPageNumber(), vo.getPageSize());

				Map<String, Object> map = new HashMap<String, Object>();

				if(vo.getDealSubType() == 2){//现场考察

					map.put("userId", UserUtils.getCurrentUserId());
					map.put("dealSubType", vo.getDealSubType());

					List<Integer> actionTypeList = new ArrayList<Integer>();
					actionTypeList.add(MyDealActionTypeEnum.LEADER_AUDIT_SITE_INSPECTION.getCode());
					actionTypeList.add(MyDealActionTypeEnum.TEAM_MEMBER_AUDIT_SITE_INSPECTION.getCode());
					map.put("actionTypeList", actionTypeList);

					pageCode.setCount(sMyDealsService.getMyDealListByParamsCounts(map));

					map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
		            map.put("pageSize", pageCode.getPageSize());
		            map.put("pageFlag", vo.getPageFlag());

					List<ExtSMyDeals> list = sMyDealsService.getMyDealListByParams(map);
					pageCode.setList(list);

					return new RestReturnResult<Object>(CommonConstants.SUCCESS, pageCode);

				}

				if(vo.getDoneOrToDo() != 0){
					map.put("userId", UserUtils.getCurrentUserId());

					if(vo.getDoneOrToDo() == 1){//待办
						map.put("doneFlag", CommonConstants.UNDONG_FLAG);
					}else if(vo.getDoneOrToDo() == 2){//已办

					}

					pageCode.setCount(sMyDealsService.getMyDealListByParamsCounts(map));

					map.put("currentRecordNum", (pageCode.getPageNo() - 1) * pageCode.getPageSize());
		            map.put("pageSize", pageCode.getPageSize());
		            map.put("pageFlag", vo.getPageFlag());

					List<ExtSMyDeals> list = sMyDealsService.getMyDealListByParams(map);
					pageCode.setList(list);

					return new RestReturnResult<Object>(CommonConstants.SUCCESS, pageCode);
				}

			}else{
				throw new RuntimeException("传参为空", new ServiceThrowable());
			}

		}catch(Exception e){
			e.printStackTrace();
			logger.error("=============getToDoListForMobileOwnApp==============e:====" + e.getMessage());
			throw new RuntimeException(e.getMessage(), e.getCause());
		}

		return restReturnResult;
	}

}
